package com.fxd.rocketmq.consumer;

import com.fxd.rocketmq.core.RocketMqEvent;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author xudongfu
 * @date 2023/02/27
 */
@Slf4j
@Component
public class TestConsumer {

    @EventListener
    public void execute(RocketMqEvent rocketMqEvent) {

        MessageExt msg = rocketMqEvent.getMsg();

        String msgStr = new String(msg.getBody());

        log.info("当前线程ThreadId: {} , 获取到消息: {}", Thread.currentThread().getId(),
                msgStr);
    }
}
